<?php
/**
 * Power by 湖北齐创云计算有限公司
 * Author: xiaohuoban
 * Create Date: 2023/8/3 09:31
 *
 */

namespace juliang\api;

// 声明API接口地址常量
define("OPEN_API_URL", "http://v2.api.juliangip.com");

class Common {

    /**
     * API接口地址
     * @var string[]
     */
    public static array $ApiUrlMap = [
        // 包时包量产品API地址
        "DYNAMIC_GET_IPS" => "/dynamic/getips",
        "DYNAMIC_SET_WHITE_IP" => "/dynamic/setwhiteip",
        "DYNAMIC_GET_WHITE_IP" => "/dynamic/getwhiteip",
        "DYNAMIC_REPLACE_WHITE_IP" => "/dynamic/replaceWhiteIp",
        "DYNAMIC_CHECK" => "/dynamic/check",
        "DYNAMIC_REMAIN" => "/dynamic/remain",
        "DYNAMIC_BALANCE" => "/dynamic/balance",

        //包时企业版产品API地址
        "COMPANY_DYNAMIC_GET_IPS" => "/company/dynamic/getips",
        "COMPANY_DYNAMIC_SET_WHITE_IP" => "/company/dynamic/setwhiteip",
        "COMPANY_DYNAMIC_GET_WHITE_IP" => "/company/dynamic/getwhiteip",
        "COMPANY_DYNAMIC_DEL_WHITE_IP" => "/company/dynamic/delwhiteip",

        // 按量付费产品API地址
        "POSTPAY_GET_IPS" => "/postpay/getips",
        "POSTPAY_SET_WHITE_IP" => "/postpay/setwhiteip",
        "POSTPAY_GET_WHITE_IP" => "/postpay/getwhiteip",
        "POSTPAY_REPLACE_WHITE_IP" => "/postpay/replaceWhiteIp",
        "POSTPAY_CHECK" => "/postpay/check",

        // 按量付费(企业版)产品API地址
        "COMPANY_POSTPAY_GET_IPS" => "/company/postpay/getips",
        "COMPANY_POSTPAY_SET_WHITE_IP" => "/company/postpay/setwhiteip",
        "COMPANY_POSTPAY_GET_WHITE_IP" => "/company/postpay/getwhiteip",
        "COMPANY_POSTPAY_DEL_WHITE_IP" => "/company/postpay/delwhiteip",

        // 不限量产品API地址
        "UNLIMITED_GET_IPS" => "/unlimited/getips",
        "UNLIMITED_SET_WHITE_IP" => "/unlimited/setwhiteip",
        "UNLIMITED_GET_WHITE_IP" => "/unlimited/getwhiteip",
        "UNLIMITED_REPLACE_WHITE_IP" => "/unlimited/replaceWhiteIp",

        // 独享代理产品API地址
        "ALONE_GET_IPS" => "/alone/getips",
        "ALONE_SET_WHITE_IP" => "/alone/setwhiteip",
        "ALONE_GET_WHITE_IP" => "/alone/getwhiteip",
        "ALONE_REPLACE_WHITE_IP" => "/alone/replaceWhiteIp",

        // 用户API地址
        "USER_GET_BALANCE" => "/user/getbalance",
    ];

    /**
     * 获取API接口地址
     * @param string $action
     * @return string
     */
    public static function getApiUrl(string $action): string
    {
        // 如果API地址不存在，则返回空
        if (!isset(self::$ApiUrlMap[$action])) {
            return "";
        }
        return OPEN_API_URL . self::$ApiUrlMap[$action];
    }
}